package com.sxpi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sxpi.mapper.BannerMapper;
import com.sxpi.mapper.NoticeMapper;
import com.sxpi.model.entity.Banner;
import com.sxpi.model.entity.Notice;
import com.sxpi.model.vo.NoticeVo;
import com.sxpi.service.NoticeService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;
    @Resource
    private BannerMapper bannerMapper;
    @Override
    public NoticeVo getAll() {
        List<Notice> notices = noticeMapper.selectList(null);
        List<Banner> banners = bannerMapper.selectList(null);

        List<String> notice = notices.stream().map(Notice::getNotice).collect(Collectors.toList());
        List<String> banner = banners.stream().map(Banner::getBannerUrl).collect(Collectors.toList());

        return new NoticeVo(notice,banner);
    }
}